package _jdk_8To15;

import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandler;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.Random;

public class About11{

  public static void main(String[] args) throws IOException, InterruptedException {
    // todo var responseAllBus = await http.get(getBusesUrl);
    //   Utf8Decoder decoder = new Utf8Decoder();
    //   var data = decoder.convert(responseAllBus.bodyBytes);
    //   if (responseAllBus.statusCode == 200) {
    //     dom.Document document = parse(data);
    //     List<dom.Element> aEliments =
    //         document.getElementsByTagName("dd").where((dom.Element e) {
    //       return e.attributes["id"] == 'selBLine';
    //     }).toList();
    //     for (dom.Element e in aEliments) {
    //       for (dom.Element child in e.children) {
    //         print(child.text);
    //         buses.add(child.text);
    //       }
    //     }
    //   } else {
    //     print('fetch buses list error ${responseAllBus.statusCode.toString()}');
    //   }
    HttpClient httpClient = HttpClient.newBuilder().build();
    HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://www.bjbus.com/home/index.php")).build();
    HttpResponse<String> response = httpClient.send(request, BodyHandlers.ofString());
    if (response.statusCode() == 200) {

    }
    String result = response.body();
    System.out.println(result);
  }


  public static void test() {
    int i = new Random().nextInt();
    System.out.println(i);

  }
}
